//
//  MyOrderCell.m
//  saler-ios
//
//  Created by 王亚陆 on 17/6/9.
//  Copyright © 2017年 sayimba. All rights reserved.
//

#import "MyOrderCell.h"
#import "Header.h"
@implementation MyOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        
        
        self.contentView.backgroundColor = WhiteColor;

        self.orderLbel = [UILabel createUIlabel:@"销售订单：" andFont:FontOfSize11 andColor:PriceColor];
        [self.contentView addSubview:self.orderLbel];
        [self.orderLbel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.contentView.mas_top).with.offset(11*kHeight);
            make.left.mas_equalTo(self.contentView.mas_left).with.offset(20*kWidth);
        }];
        self.orderNumber = [UILabel createUIlabel:@"S023578901" andFont:FontOfSize11 andColor:PriceColor];
        [self.contentView addSubview:self.orderNumber];
        [self.orderNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.orderLbel.mas_centerY);
            make.left.mas_equalTo(self.orderLbel.mas_right).with.offset(1*kWidth);
        }];
        
        self.orderState = [UILabel createUIlabel:@"待审批" andFont:FontOfSize10 andColor:PriceColor];
        [self.contentView addSubview:self.orderState];
        [self.orderState mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.orderLbel.mas_centerY);
            make.right.mas_equalTo(self.contentView.mas_right).with.offset(-20*kWidth);
        }];
        
        
        self.orderStateImage = [[UIImageView alloc]init];
        [self.contentView addSubview:self.orderStateImage];
        [self.orderStateImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.orderState.mas_centerY);
            make.right.mas_equalTo(self.orderState.mas_left).with.offset(-5*kWidth);
            make.size.mas_equalTo(CGSizeMake(9*kWidth, 9*kHeight));
        }];

        

        UIView * Hline1 =[[UIView alloc]init];
        Hline1.backgroundColor = GrayColor;
        [self.contentView addSubview:Hline1];
        [Hline1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right);
            make.top.mas_equalTo(self.orderLbel.mas_bottom).with.offset(11*kHeight);
            make.size.mas_equalTo(CGSizeMake(Main_Width, 1*kHeight));
        }];

        
        
        self.orderBegainAdd = [UILabel createUIlabel:@"广州市" andFont:FontOfSize14 andColor:littleColor];
        [self.contentView addSubview:self.orderBegainAdd];
        
        [self.orderBegainAdd mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.orderNumber.mas_left);
            make.top.mas_equalTo(Hline1.mas_bottom).with.offset(30*kHeight);
        }];

        
        UIView * Hline2 =[[UIView alloc]init];
        Hline2.backgroundColor = WhiteColor;
        [self.contentView addSubview:Hline2];
        [Hline2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.orderNumber.mas_left);
            make.top.mas_equalTo(self.orderBegainAdd.mas_bottom).with.offset(5*kHeight);
            make.size.mas_equalTo(CGSizeMake(225*kWidth, 1*kHeight));
        }];
        
        self.orderEndAdd = [UILabel createUIlabel:@"璧山" andFont:FontOfSize14 andColor:littleColor];
        [self.contentView addSubview:self.orderEndAdd];
        
        [self.orderEndAdd mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(Hline2.mas_right);
            make.centerY.mas_equalTo(self.orderBegainAdd.mas_centerY);
            make.width.mas_equalTo(100*kWidth);
        }];
        
        self.orderAddImage  = [[UIImageView alloc]init];
        [self.contentView addSubview:self.orderAddImage];
        [self.orderAddImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(Hline2.mas_centerX);
            make.bottom.mas_equalTo(Hline2.mas_top).with.offset(-5*kHeight);
            make.size.mas_equalTo(CGSizeMake(16*kWidth, 16*kHeight));
        }];
        

        
        self.orderCar = [UILabel createUIlabel:@"5个品牌，5台车" andFont:FontOfSize11 andColor:UIbtnColor];
        
        [self.contentView addSubview:self.orderCar];
        [self.orderCar mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(Hline2.mas_centerX).with.offset(30*kWidth);
            make.top.mas_equalTo(Hline2.mas_bottom).with.offset(10*kHeight);
        }];
        
        self.orderTime = [UILabel createUIlabel:@"2017-10-10" andFont:FontOfSize11 andColor:UIbtnColor];
        [self.contentView addSubview:self.orderTime];
        [self.orderTime mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.orderCar.mas_centerY);
            make.right.mas_equalTo(self.orderCar.mas_left).with.offset(-15*kWidth);
        }];
        
        UIView * Hline3 =[[UIView alloc]init];
        Hline3.backgroundColor = UIviewBackColor;
        [self.contentView addSubview:Hline3];
        [Hline3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.orderNumber.mas_left);
            make.top.mas_equalTo(self.orderTime.mas_bottom).with.offset(5*kHeight);
            make.size.mas_equalTo(CGSizeMake(225*kWidth, 1*kHeight));
        }];
        

        
        UIView * line = [[UIView alloc]init];
        line.backgroundColor = UIviewBackColor;
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.contentView.mas_centerX);
            make.bottom.mas_equalTo(self.contentView.mas_bottom);
            make.size.mas_equalTo(CGSizeMake(Main_Width, 10*kHeight));
        }];
        
        self.payMoneyLabel = [UILabel createUIlabel:@"付款金额：￥111" andFont:FontOfSize11 andColor:UIbtnColor];
        [self.contentView addSubview:self.payMoneyLabel];
        [self.payMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.orderLbel.mas_left);
            make.bottom.mas_equalTo(line.mas_top).with.offset(-10*kHeight);
        }];
        
       self.pay = [UILabel createUIlabel:@"付款审核：" andFont:FontOfSize11 andColor:UIbtnColor];
        self.payStatueLabel = [UILabel createUIlabel:@"未提交" andFont:FontOfSize11 andColor:RedColor];
        
        [self.contentView addSubview:self.pay];
        [self.contentView addSubview:self.payStatueLabel];
        
        [self.pay mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).with.offset(-50*kWidth);
            make.centerY.mas_equalTo(self.payMoneyLabel.mas_centerY);
        }];
        [self.payStatueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.pay.mas_right);
            make.centerY.mas_equalTo(self.payMoneyLabel.mas_centerY);
        }];


    }
    return self;
    
}

-(void)showInfo:(NSDictionary *)dic_info {

//        auditStatus = "<null>";
//        brandSeries = "2\U4e2a\U54c1\U724c\Uff0c6\U53f0\U8f66";
//        code = SO873389901549748224;
//        departContact = "\U5019\U5efa\U6167";
//        departPhone = 15210491697;
//        departRegionName = "\U6df1\U5733\U5e02";
//        destContact = "\U5019\U5efa\U6167";
//        destPhone = 15210491697;
//        destRegionName = "\U77f3\U5bb6\U5e84";
//        id = 2;
//        orderStatus = 10;
//        orderStatusText = "\U5f85\U5ba1\U6279";
//        pickDate = "2017-06-10 00:00:00";
//        userId = 1;

    //attachAuditStatus  10 未提交 20已提交 30 已通过 40 未通过
    //attachAuditStatusText
    
    self.orderNumber.text = [NSString stringWithFormat:@"%@",dic_info[@"code"]];
    self.orderBegainAdd.text = [NSString stringWithFormat:@"%@",dic_info[@"departRegionName"]];
    self.orderEndAdd.text = [NSString stringWithFormat:@"%@",dic_info[@"destRegionName"]];
    self.payStatueLabel.text = [NSString stringWithFormat:@"%@",dic_info[@"attachAuditStatusText"]];

    int  attachAuditStatus = [dic_info[@"attachAuditStatus"] intValue];
    
    switch (attachAuditStatus) {
        case 10:
            self.payStatueLabel.textColor = Color_RGB(255, 152,0,1);
            break;
        case 20:
            self.payStatueLabel.textColor = Color_RGB(3, 164, 255,1);
            break;
        case 30:
            self.payStatueLabel.textColor = Color_RGB(37, 155, 36,1);
            break;
        case 40:
            self.payStatueLabel.textColor = Color_RGB(229, 28, 35,1);
            break;
        default:
            break;
    }
    
    
    self.payMoneyLabel.text = [NSString stringWithFormat:@"付款金额：￥%@",dic_info[@"suggestSalePrice"]];
    
    NSString * timer = [dic_info[@"pickDate"] substringToIndex:10];
    self.orderTime.text = timer;
    self.orderCar.text = [NSString stringWithFormat:@"%@",dic_info[@"brandSeries"]];
    self.orderState.text = [NSString stringWithFormat:@"%@",dic_info[@"orderStatusText"]];

    NSString * orderStatus = [NSString stringWithFormat:@"%@",dic_info[@"orderStatus"]];
    
    NSString * auditStatus = [NSString stringWithFormat:@"%@",dic_info[@"auditStatus"]];
    //待审核
    if ([auditStatus isEqualToString:@"10"]) {
        
        self.orderStateImage.image = [UIImage imageNamed:@"daishenhe1"];
        
    }else{
        self.orderStateImage.image = [UIImage imageNamed:@"daishenhe2"];
    }
    
    
    if ([orderStatus isEqualToString:@"10"]) {

        self.orderAddImage.image = [UIImage imageNamed:@"daishenhe"];
        
    }else if ([orderStatus isEqualToString:@"20"]){

        self.orderAddImage.image = [UIImage imageNamed:@"daijiedan"];
        self.orderStateImage.image = [UIImage imageNamed:@"daijiedan1"];

        
    }else if ([orderStatus isEqualToString:@"30"]){

        self.orderAddImage.image = [UIImage imageNamed:@"yijiedan"];
        self.orderStateImage.image = [UIImage imageNamed:@"yijiedan1"];
        

        
    }else if ([orderStatus isEqualToString:@"40"]){

        self.orderAddImage.image = [UIImage imageNamed:@"yijiaoche"];
        self.orderStateImage.image = [UIImage imageNamed:@"yijiaoche1"];
        

        
    }else {

        self.orderAddImage.image = [UIImage imageNamed:@"yishoukuan"];
        self.orderStateImage.image = [UIImage imageNamed:@"yishoukuan1"];
        

    }
    
    
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
